//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: baseJs.imgUrl,
    uid: "",
    orderData: [],
    pageIndex: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      uid: wx.getStorageSync('uid'),
    })
  },

  //加载列表
  GetUserNotCommantOrder: function () {
    var that = this;
    var uid = this.data.uid;
    var pageIndex = this.data.pageIndex;
    var orderData = this.data.orderData;
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=GetUserNotCommantOrder&UID=" + uid + "&PageSize=10&PageIndex=" + pageIndex),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data)).ResultData;
        console.log(JSON.parse(baseJs.decryUrl(res.data)));
        for (var i = 0; i < json.length; i++) {
          orderData.push(json[i])
        }
        that.setData({
          orderData: orderData,
        })
        if (json.length == 10) {
          that.setData({
            state: 'loadMore',
          })
        } else if (json.length == 0 && pageIndex == 1) {
          that.setData({
            state: 'noData',
          })
        } else if (json.length < 10) {
          that.setData({
            state: 'noMore',
          })
        } else if (json.length == 0 && pageIndex > 1) {
          that.setData({
            state: 'noMore',
          })
        }
      }
    })
  },
  // 评价
  goEvaluate: function (e) {
    wx.navigateTo({
      url: '/packageA/evaluate/evaluate?orderId=' + e.currentTarget.dataset.orderid,
    })
  },
})